<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        用户姓名：<input type="text" v-model="user.name">
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                message: '',
                user: {
                    name: "zhangsan",
                    gender: 'male'
                }
            },
            methods: {},
            computed: {},
            // 回调值为一个对象，对象属性包含处理器， 是否是深度遍历监控
            watch: {
                'user': {
                    handler: function (newValue, oldValue) {
                        console.log(`新值：${newValue.name} ----- 旧值：${oldValue.name}`)
                    },
                    // 设置为深度遍历监控
                    deep: true
                }
            }
        })
    </script>
</body>

</html>